import React ,{Component}from "react"
export default class Form3 extends Component{
    state={
        username:'',
        password:''
    }
    showData=(dataType)=>{
        return (event)=>{
            this.setState({[dataType]:event.target.value}); //函数的柯里化
        }
    }
    onHandleForm=(event)=>{
        event.preventDefault();
        console.log(this.state.username,this.state.password);
    }
    render() {
        return(
            <form onSubmit={this.onHandleForm}>
                <input type={"text"} onChange={this.showData('username')}  placeholder={"账号"} name={"username"} />
                <input type={"text"}  onChange={this.showData('password')} placeholder={"密码"} name={"password"} />
                <button>提交</button>
            </form>
        )
    }
}
